/************************************************************************
 *				SRLOS Team CopyRight
 *@file		mem_physical.c
 *@author	bloceanc
 *@date		7/12/2010
 *@note		physical memory management(page managerment)
 ************************************************************************/

#ifndef	_MEM_PHYSICAL_H_
#define	_MEM_PHYSICAL_H_

/*
 * physical memory managerment
 *	like heap managerment.just link free pages into page blocks.the max count of page blocks is page count >> 2
 * Every memory physical page descriped by one descriptor
 */
#define	K_MEM_PHY_PAGE_FLAG_SYSUSING	0x1		// used in system mode
#define	K_MEM_PHY_PAGE_FLAG_USRUSING	0x0		// used in user mode
#define	K_MEM_PHY_PAGE_FLAG_READONLY	0x2		// used in read-only mode

#define	K_MEM_PHY_PAGE_FLAG_
/** page block structure */
typedef struct k_mem_phy_page_block_struct{
	unsigned int page_count;	/* page count of current page block */
	unsigned int page_start_idx;	/* start page index of current page block */
	struct k_mem_phy_page_block_struct *next;	/* next page block structure pointer */
	struct k_mem_phy_page_block_struct *prev;	/* previous page block structure pointer */
}k_phy_pageblock;

/** page information structure */
typedef	struct k_mem_phy_page_struct{
	unsigned short _ref_fork;	/* fork references, process count of shared */
	unsigned short _ref_count;	/* current page references */
	unsigned int _flag;	/* page flag  see flag macros for more informations */
	k_phy_pageblock *_block_pt;	/* block index of this page if this page is free */
}k_mem_phy_page;

#endif	/* _MEM_PHYSICAL_H_ */
